package cl.pds.pruebacliente;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class PacientesAdapter extends ArrayAdapter<Paciente> {

	private Context mContext;
	private List<Paciente> mObjects;

	static class ViewHolder {
		public TextView Nombre;
		public TextView RUT;
	}

	public PacientesAdapter(Context context, int textViewResourceId,
			List<Paciente> objects) {
		super(context, textViewResourceId, objects);
		mContext = context;
		mObjects = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView = convertView;
		if (rowView == null) {
			LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			rowView = inflater.inflate(R.layout.activity_pacientes_item, null);
			ViewHolder viewHolder = new ViewHolder();
			viewHolder.Nombre = (TextView) rowView.findViewById(R.id.activity_pacientes_item_txtNombre);
			viewHolder.RUT = (TextView) rowView.findViewById(R.id.activity_pacientes_item_txtRUT);
			rowView.setTag(viewHolder);
		}

		ViewHolder holder = (ViewHolder) rowView.getTag();
		holder.Nombre.setText(mObjects.get(position).getNombre());
		holder.RUT.setText(mObjects.get(position).getRUT());

		return rowView;
	}
}

